/*
 * Copyright (c) 2006-2017, Yunnan Sanjiu Network technology Co., Ltd.
 * 
 * All rights reserved.
 */
package com.niguang.labour.common.config.serializer;


import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.niguang.labour.common.util.MoneyUtil;

import java.io.IOException;
import java.math.BigDecimal;

/**
 * @author  Administrator on 2017/6/29.
 */
public class BigDecemal2StringSerializer extends JsonSerializer<BigDecimal> {

    public static final BigDecemal2StringSerializer instance = new BigDecemal2StringSerializer();

    @Override
    public void serialize(BigDecimal aBigDecimal, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
            throws IOException {

        String doubleStr = MoneyUtil.formatMoney2Decimal(aBigDecimal + "");
        jsonGenerator.writeString(doubleStr);
    }

}
